#pragma once

#define _CRT_SECURE_NO_WARNINGS

#include <cstring>
#include <cassert>
#include <jvmti.h>
#include <jni.h>

double GetTimeSec();
//void CheckError(int error, const char* msg);

#define CheckError(error, msg) \
	if (error != JVMTI_ERROR_NONE) \
	{ \
		printf("[Agent] ERROR: can't %s, error code: %d, line %d, file %s\n", msg, error, __LINE__, __FILE__); \
	}

class Logger
{
public:
	static Logger* CreateLogger(const char* filename);
	void BeginRecord(const char* fmt, ...);
	void Record(const char* fmt, ...);
	void EndRecord();
	~Logger();
private:
	FILE* fout;
	bool isEvent;
};

void DumpCallStack(jthread thread, bool fromOne);

extern jvmtiEnv *GJvmti;
extern Logger* LogClasses;
extern Logger* LogMethods;
extern Logger* LogEvents;
